package com.xinqi.modules.exam.student.dto.rsp;

import com.xinqi.common.base.dto.CommonFileDTO;
import com.xinqi.common.base.dto.QuestionBaseDTO;
import com.xinqi.common.base.enums.QuestionTypeEnum;
import com.xinqi.modules.exam.student.enums.PaperErrorSetTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

/**
 * 课程测评学生错题集-响应对象
 *
 * @author: linkai
 * @date: 2023/07/02
 */
@Data
@Schema(description = "课程测评学生错题集-响应对象")
public class CourseExamPaperErrorSetResultDTO implements Serializable {
    /**
     * 主键
     */
    @Schema(description = "主键", example = "")
    private Long id;
    /**
     * 租户ID
     */
    @Schema(description = "租户ID", example = "")
    private Long tenantId;
    /**
     * 创建者
     */
    @Schema(description = "创建者", example = "")
    private Long createBy;
    /**
     * 创建时间
     */
    @Schema(description = "创建时间", example = "")
    private LocalDateTime createTime;
    /**
     * 班级ID
     */
    @Schema(description = "班级ID", example = "")
    private Long classId;
    /**
     * 测评ID
     */
    @Schema(description = "测评ID", example = "")
    private Long examPaperId;
    /**
     * 学生ID
     */
    @Schema(description = "学生ID", example = "")
    private Long studentId;
    /**
     * 题目id
     */
    @Schema(description = "题目id", example = "")
    private Long questionId;
    /**
     * 题集类型，1-错题集；2-星标题
     */
    @Schema(description = "题集类型，1-错题集；2-星标题", example = "")
    private PaperErrorSetTypeEnum type;
    /**
     * 题目类型
     */
    @Schema(description = "题目类型", example = "")
    private QuestionTypeEnum questionType;
    /**
     * 题目详情
     */
    @Schema(description = "题目详情", example = "")
    private QuestionBaseDTO question;
    /**
     * 题目详情
     */
    @Schema(description = "题目详情", example = "")
    private QuestionBaseDTO 答案;
    /**
     * 备注
     */
    @Schema(description = "备注", example = "")
    private String remark;
    /**
     * 星题集ID
     */
    @Schema(description = "星题集ID", example = "")
    private Long starId;
    /**
     * 错题集ID
     */
    @Schema(description = "错题集ID", example = "")
    private Long errorId;
    /**
     * 学生答案
     */
    @Schema(description = "学生答案", example = "")
    private String studentAnswer;
    /**
     * 学生答案文件
     */
    @Schema(description = "学生答案文件", example = "")
    private List<CommonFileDTO> studentAnswerFiles;


    public void init(Long tId) {
        if (Objects.equals(type, PaperErrorSetTypeEnum.错题集)) {
            this.errorId = this.id;
            this.starId = tId;
        } else {
            this.starId = id;
            this.errorId = tId;
        }
    }

}
